-
Notifications
You must be signed in to change notification settings - Fork 13.4k
fix: added a normalization step for MathJax-style \[\] and \(\) delimiters #16599
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: added a normalization step for MathJax-style \[\] and \(\) delimiters #16599
Conversation
35ee04c
to
99957e3
Compare
…iters So inline and block equations are converted before KaTeX rendering, enabling proper display of model-generated LaTeX in the WebUI
99957e3
to
877f0bd
Compare
Sorry for the spam : I had two versions coexisting in my Git history, so I reverted to the simple version that works on its own, without the remark plugin. |
Settings layout : #16607 |
Hi @ServeurpersoCom , in #16508 there are test-samples in https://github.com/ggml-org/llama.cpp/pull/16508/files#diff-22e3b93a74a89292e31a9c73b38e1e011c26b28f0715369f30f5a8d1090ea750 . |
I’ll take a look at your test samples: that seems like a really good idea. Take a look at my proposal: it’s much simpler now, just one function. Implementing it as a remark plugin was making things more complex. The remark MathJax plugin rewrites the Markdown AST too aggressively, replacing whole subtrees and risking broken output whenever nested markup or edge cases appear. A simple regex-based pre-normalization that converts math delimiters before parsing avoids all that complexity, it lets the standard remark-math plugin do the job safely. Fewer moving parts mean less maintenance, fewer bugs, and the same rendering quality without the AST surgery. |
So inline and block equations are converted before KaTeX rendering, enabling proper display of model-generated LaTeX in the WebUI:
Added a dedicated remarkMathJaxDelimiters plugin that rewrites MathJax bracket delimiters into KaTeX-friendly dollar math while limiting the normalization to text nodes so code blocks and other literals remain untouched.
Wired the new plugin into the existing Markdown processor ahead of remark-math and dropped the prior global string replace, keeping the established remark/rehype pipeline intact while still rendering centered and inline equations correctly.
Missing stage in #16505 because of KaTeX
Close #16598